import Vue from 'vue'
// import Vuex from 'vuex'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import qs from 'qs';
import Cookies from 'js-cookie';
import 'lib-flexible'
// Vue.use(Vuex)
Vue.use(ElementUI);
Vue.prototype.$axios = axios;
Vue.config.productionTip = false;
Vue.prototype.$qs = qs;
// axios.defaults.baseURL = 'http://81.68.133.117:8080/dormitory';
axios.defaults.headers.common['token'] = localStorage.getItem('token')
axios.defaults.baseURL = 'http://192.168.137.1:80/';
// axios.defaults.headers.token = this.$store.state.token;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
// axios.defaults.withCredentials = true;

axios.interceptors.request.use(config => {
  if (config.push === '/login') {
  } else {
    if (localStorage.getItem('token')) {
      //在请求头加入token，名字要和后端接收请求头的token名字一样 
      config.headers.token = localStorage.getItem('token');
    }
  }
  return config;
},
  error => {
    return Promise.reject(error);
  });

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app');
